<h5>Interfacing the Wiring hardware using MIDI protocol</h5>
<p>This tutorial introduces the basic interfacing of the Wiring hardware using the MIDI protocol. The brief for the tutorial will be to read simple values from the Wiring board using the MIDI protocol to Ableton Live <a href="http://www.ableton.com/">http://www.ableton.com/</a>. It assumes the Wiring software and Ableton Live are installed and the proper Wiring setup has been previously completed. For more Information on Wiring install check out the <a href="http://wiring.org.co/learning/tutorials/">tutorials</a> about Wiring installation and software setup.</p>
<h5>Step 1</h5>
<p>Copy and paste the following code on the Wiring editor: Verify your program is free of compiling errors by pressing the Compile/Verify button in the menu bar. Press the Upload button in the menu bar. In case of syntax errors the Wiring environment will print the error messages otherwise it will print the Upload was completed successfully, the uploading process triggers activity in the Rx/Tx LEDs on the Wiring hardware. The new program will start automatically after uploading. Use the Serial Monitor button to watch the data coming from the Wiring board, then close the Serial Monitor again.</p>
<pre>
/** 
 * Switch / MIDI

 * 
 * Reads values from a switch connected to the 
 * digital input pin 8. 
 * http://wiring.org.co/learning/basics/switch.html
 */
void setup() {
  // Set MIDI baud rate:
  Serial.begin(57600);
  //Switch pin
  pinMode(8,INPUT);
  //WLED
  pinMode(WLED,OUTPUT);
}

void loop() {
  if(digitalRead(8)==HIGH) {
    //Note on channel 1 (0x90), some note value, middle velocity (0x45):
    noteOn(0x90, 1, 0x45);
    digitalWrite(WLED,HIGH);
  }
  else {
    digitalWrite(WLED,LOW);
  }
}

//  plays a MIDI note.  Doesn't check to see that
//  cmd is greater than 127, or that data values are  less than 127:
void noteOn(int cmd, int pitch, int velocity) {
  Serial.write(cmd);
  Serial.write(pitch);
  Serial.write(velocity);
}
</pre>
<p>&nbsp;</p>
<h5>Step 2</h5>
<p>Build the circuit.</p>
<p><img src="imgs/MIDI.png"/></p>
<h5>Step 3</h5>
<p><b>Windows:</b></p>
<p>Download MIDI Yoke from MIDI-OX <a href="http://www.midiox.com/">here</a>.</p>
<p>After installing MIDI Yoke, it recommended to go into Control Panel and change the port. You will need to reboot after changing the number of ports.</p>
<p><img src="imgs/midi_01.png" width="255" height="242" /></p>
<p><b>Mac OS X:</b></p>
<p>Note: Apple has released a Java update the reintegrates native MIDI support into the Java. This means that as of Apple's Java 6 update, you will no longer require mmj.jar and libmmj.jnilib.</p>
<p>Step 1</p>
<p>Install Apple's Audio MIDI Setup (comes with your OS, in your Applications folder / Utilities) and mmj which can be downaloaded <a href="http://www.humatic.de/htools/mmj.htm">here</a>.</p>
<p>Step 2</p>
<p>Copy mmj y libmmj.jnilib in /Library/Java/Extensions.</p>
<p>Step 3</p>
<p>Run Audio MIDI Setup, then double click on the IAC Driver.</p>
<p>Now in the IAC driver, click the "More Information" triangle if it is not showing already.</p>
<p><img src="imgs/midi_02.png" width="373" height="402" /></p>
<p>Step 4</p>
<p>In the lower left; double click the MIDI port name to edit it and click the + to add a new port.</p>
<p>Step 5</p>
<p>Important, check the "Device is online" box or nothing will work</p>
<p>Step 6</p>
<p>Click "Apply", and now you are done. You may quit the Audio MIDI Setup software, it does not need to be running for the SM to work.</p>
<p></p>
<p>&nbsp;</p>
<h5>Step 4</h5>
<p>Run and setup Ableton Live. Open the prefences and go to the MIDI Sync tab. In Control Surface choose None, in Input choose In From MIDI Yoke: 1 for Windows or IAC Driver (Input from Audio Software) for Mac OS X and in output choose Out From MIDI Yoke: 1 for Windows or IAC Driver (Output to Audio Software) for Mac OS X.</p>
<p><img src="imgs/midi_04.png" width="406" height="510" /></p>
<h5>Step 5</h5>
<p>Set the MIDI map.</p>
<img src="imgs/midi_05.png" width="466" height="350" />
<p>&nbsp;</p>
<p>Next &gt;&gt; <a href="midi2.html">Interfacing the Wiring hardware using MIDI protocol using a Serial converter.</a></p>